package com.haircut.project.controller.record;

import com.haircut.project.service.salary.ISalaryService;
import com.haircut.project.vo.record.RecordReqVo;
import com.haircut.project.vo.record.RecordResVo;
import com.haircut.project.vo.salary.SalaryReqVo;
import com.haircut.project.vo.salary.SalaryResVo;
import com.modular.result.PageResult;
import com.modular.result.RspMessage;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/b/salary")
public class SaleController {
    @Autowired
    private ISalaryService salaryService;

    /**
     * 查询分类列表
     * @return
     */
    @ApiOperation(value = "计算工资")
    @GetMapping("calcSalary")
    public RspMessage<Void> checkRecord(){
//        salaryService.calcSalary();
        return RspMessage.success();
    }

    /**
     * 查询分类列表
     * @return
     */
    @ApiOperation(value = "查询分类信息")
    @PostMapping("findPage")
    public RspMessage<PageResult<SalaryResVo>> findPage(@RequestBody SalaryReqVo reqVo){
        return RspMessage.success(salaryService.findManagerPage(reqVo));
    }

    /**
     * 发工资
     * @return
     */
    @ApiOperation(value = "发工资")
    @GetMapping("salarySend")
    public RspMessage<Void> salarySend(@ApiParam("发工资") @RequestParam("salaryId") String salaryId){
        salaryService.salarySend(salaryId);
        return RspMessage.success();
    }

    /**
     * 重新计算
     * @return
     */
    @ApiOperation(value = "重新计算")
    @GetMapping("recalculation")
    public RspMessage<Void> recalculation(@ApiParam("重新计算") @RequestParam("salaryId") String salaryId){
        salaryService.recalculation(salaryId);
        return RspMessage.success();
    }
}
